/**
 * Created by alan on 2017/4/27.
 * 水文测站基本信息
 */
Ext.define('Admin.view.baseInfo.RiverBaseInfo', {
    extend: 'Ext.container.Container',
    xtype: 'riverBaseInfo',
    requires: [
        'Admin.store.baseInfo.RiverBasinInfo'
    ],
    //起别名
    alias: 'riverBaseInfo',
    controller: 'riverBaseController',
    userCLs: 'big-100 small-100',
    margin: 7,
    bodyPadding: 7,
    layout: {
        type: 'vbox',
        align: 'stretch' //拉伸使其充满整个父容器
    },
    height: 200,
    autoLoad: true,
    items: [{
        xtype: 'panel',
        height: 50,
        items: [{
            tbar: [
                //        {
                //        xtype: "textfield",
                //        maxWidth: 220,
                //        fieldLabel: "测站名称",
                //        labelWidth: 60,
                //        reference: "stNm",
                //      },
                {
                    xtype: "combobox",
                    maxWidth: 220,
                    fieldLabel: "测站名称",
                    reference: "stNm",
                    displayField: 'stNm',
                    queryMode: 'local',
                    valueField: 'stNm',
                    triggerAction: 'all',
                    anyMatch: true,
                    labelWidth: 60,
                    listeners: {
                        added: function(combo) {
                            var _that = this;
                            var store = Ext.create("Ext.data.Store", {
                                fields: ["stNm", "stcd", 'stTp'],
                                data: statList
                            });
                            store.filter({
                                property: 'river',
                                value: config.RIVER
                            });
                            combo.setStore(store);
                        }
                    }
                },
                {
                    xtype: "button",
                    text: "查询",
                    iconCls: 'x-fa  fa-file-o',
                    handler: 'check',
                    margin: '0 10 0 10',
                    style: 'border-radius:4px;-webkit-border-radius: 4px;'
                }
            ],
            margin: '0 0 10 0'
        }, ]
    }, {
        xtype: 'gridpanel',
        bufferedRenderer: true,
        title: '测站基础信息',
        flex: 1,
        scrollable: true,
        reference: 'riverGrid',
        columns: [{
                header: '测站编号',
                flex: 1,
                dataIndex: 'stcd',
                align: 'center',
                width: '10%'
            },
            {
                header: '测站名称',
                dataIndex: 'stNm',
                align: 'center',
                width: '20%'
            },
            {
                header: '所在地',
                dataIndex: 'loc',
                align: 'center',
                width: '40%'
            },
            {
                header: '设站年月',
                dataIndex: 'estStYm',
                align: 'center',
                width: '11.8%'
            },
            {
                header: '时间',
                dataIndex: 'ts',
                align: 'center',
                width: '18%',
                // renderer: Ext.util.Format.dateRenderer('Y-m-d h:i:s')
                renderer: function(value) {
                    if (/\.0$/.test(value)) {
                        return value.substring(0, 19);
                    } else { return value; }
                }
            }
        ],
        store: {
            type: 'riverBaseInfo'
        },
        bbar: {
            xtype: 'pagingtoolbar',
            displayInfo: true,
            displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
            emptyMsg: "没有记录",
        },
        stripeRows: true,
        columnLines: true,
        plugins: {
            ptype: 'cellediting',
            clicksToEdit: 1
        }
    }]
})